﻿using System.Reflection;
using AnyTap.Views;
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Views;
using CommunityToolkit.Mvvm.Input;
using static AnyTap.Services.Helper;
namespace AnyTap.ViewModels;

public partial class SettingViewModel : BaseViewModel
{
	#region 定义
	private static readonly AssemblyName assembly = Assembly.GetExecutingAssembly().GetName();
	private static readonly Version version = assembly.Version;

	#region 属性
#if DEBUG
	public string Title => $"DEBUG v{version}";
#else
	public string Title => $"{assembly.Name} v{version}";
#endif
	#endregion

	#region 命令
	[RelayCommand]
	private static async Task Reset() => await Shell.Current.ShowPopupAsync(new AuthPopup());
	#endregion
	#endregion

	public override async Task OnDisappearing()
	{
		Settings.WriteObject(FILE_SETTING);
		await Toast.Make("系统设置已保存").Show();
		await base.OnDisappearing();
	}
}
